Problem Note 51683: The FCMP procedure might return incorrect results with the CAT function
When variables that are passed to the FCMP procedure are used with the CAT function, the results are correct. However, if you use new variables with the CAT function that were created using variables that are passed to the FCMP procedure, the results are truncated to the first argument of the CAT function.
The example code below illustrates the truncation of the result of the CAT function with PROC FCMP:
proc fcmp outlib=work.funcs.samples;
function abc(a $, b $) $;
fa=a;
fb=b;
return(Cat(FA,FB));
endsub;
quit;
options cmplib=work.funcs;
data one;
a='hello';
b='there';
newvar=abc(a,b);
run;
proc print;
run;
The result of NEWVAR is "hello" and not "hello there".
To circumvent the issue, you can add a LENGTH statement inside PROC FCMP and create a new variable that is the result of the CAT function. The modified PROC FCMP code is shown below:
proc fcmp outlib=work.funcs.samples;
function abc(a $, b $) $;
length temp $15 fa $6 fb $6;
fa=a;
fb=b;
temp=cat(fa,fb);
return(temp);
endsub;
quit;
Operating System and Release Information
SAS System | Base SAS | Solaris for x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Linux | 9.3 TS1M0 | 9.4 TS1M7 |
Linux for x64 | 9.3 TS1M0 | 9.4 TS1M7 |
HP-UX IPF | 9.3 TS1M0 | 9.4 TS1M7 |
64-bit Enabled Solaris | 9.3 TS1M0 | 9.4 TS1M7 |
64-bit Enabled HP-UX | 9.3 TS1M0 | 9.4 TS1M7 |
64-bit Enabled AIX | 9.3 TS1M0 | 9.4 TS1M7 |
Windows Vista for x64 | 9.3 TS1M0 | |
Windows 7 Ultimate x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Windows Vista | 9.3 TS1M0 | |
Windows 7 Ultimate 32 bit | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Professional x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Professional 32 bit | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Home Premium x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Home Premium 32 bit | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Enterprise x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Windows 7 Enterprise 32 bit | 9.3 TS1M0 | 9.4 TS1M7 |
Microsoft Windows XP Professional | 9.3 TS1M0 | |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M0 | 9.4 TS1M7 |
Microsoft Windows Server 2008 R2 | 9.3 TS1M0 | 9.4 TS1M7 |
Microsoft Windows Server 2008 | 9.3 TS1M0 | 9.4 TS1M7 |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M0 | |
Microsoft® Windows® for x64 | 9.3 TS1M0 | 9.4 TS1M7 |
z/OS | 9.3 TS1M0 | 9.4 TS1M7 |
Z64 | 9.3 TS1M0 | 9.4 TS1M7 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Problem Note |
Priority: | medium |
Topic: | SAS Reference ==> Procedures ==> FCMP SAS Reference ==> Functions ==> Character ==> CAT
|
Date Modified: | 2023-01-17 10:46:03 |
Date Created: | 2013-11-22 13:19:36 |